/*
package com.yuke.cloud.service.omc.config;

import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

import java.util.concurrent.Executor;

@Component
@EnableAsync
public class ThreadConfig implements AsyncConfigurer {
    @Override
    public Executor getAsyncExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        //核心线程数cpu数量加2，最大线程数cpu数量的二倍，当设置队列长度为最大的时候，最大线程数就失效了
        // ，应为永远也填不满队列长度，当队列长度达到设置的长度后才创建新的线程，当达maxpoll的时候，如果在
        //向execute里面添加任务，就会报错，reject接受任务
        executor.setCorePoolSize(Runtime.getRuntime().availableProcessors()+2);
        executor.setMaxPoolSize(Runtime.getRuntime().availableProcessors()*2);
        executor.setQueueCapacity(Integer.MAX_VALUE);
        executor.initialize();
        return executor;
    }

    @Override
    public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
        return null;
    }
}
*/
